import IPy
import subprocess
import threading

ip = IPy.IP("192.168.0.0/24")
fp = open("ip.txt","w+")

def scan_ip(ip):
    result = subprocess.run(f"ping {ip} -c 1 -w 1",shell=True)
    if result.returncode == 0:
        fp.write(f"{ip}已被使用\n")
    else:
        fp.write(f"{ip}还未使用\n")

t_lst = []
for i in ip:
    t = threading.Thread(target=scan_ip,args=(i,))
    t_lst.append(t)
    t.start()

for t in t_lst:
    t.join()
































